package jh.com.jhappbf.datamanager;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import jh.com.jhappbf.R;

/**
 * @author : wwh
 * e-mail : 953889276@qq.com
 * time   : 2018/9/8 15:02
 * desc   : 维护cizu表（添加，删除收发货，货名，类型等字段）
 */
public class DataManager extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.data_manager_fragment, null);
        initView(view);
        return view;
    }

    private void initView(View view) {
        ListView listView = view.findViewById(R.id.data_manager_listView);
        String[] strings = {"货名管理", "类型管理", "发货管理", "收货管理", "规格管理", "卸货区域管理"};
        listView.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, strings));

        listView.setOnItemClickListener((parent, view1, position, id) -> {
            Intent intent = new Intent(getActivity(), FieldManagerActivity.class);
            String flag = "";
            switch (position) {
                case 0:
                    flag = "h";
                    break;
                case 1:
                    flag = "l";
                    break;
                case 2:
                    flag = "f";
                    break;
                case 3:
                    flag = "s";
                    break;
                case 4:
                    flag = "g";
                    break;
                case 5:
                    flag = "x";
                    break;
                default:

            }
            intent.putExtra("flag", flag);
            startActivity(intent);
        });
    }

}
